Repository navigation
Roll back failed and undone inputs, and add a checkpoint for Undo - #1174
conrade-ctc wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1174 +/- ##
==========================================
+ Coverage 88.86% 89.32% +0.46%
==========================================
Files 24 25 +1
Lines 7014 7318 +304
==========================================
+ Hits 6233 6537 +304
Misses 781 781
🚀 New features to boost your workflow:
|
mcbarton
left a comment
There was a problem hiding this comment.
Plus you want to add _ZN5clang11Interpreter18getExecutionEngineEv to the list of exported symbols here https://github.com/chicagotrading/CppInterOp/blob/undo-failed-inputs-upstream/lib/CppInterOp/exports.ld . Unless I missed one of the symbols, this should fix your undefined symbol errors for the wasm ci.
14e6dfe to
683a760
Compare
|
Thanks. The link check is the only new code that calls |
c76eac2 to
ddcde50
Compare
A failed Declare, Process or Evaluate leaves the interpreter as it was before the input: - An input that parses but fails to link or to run is withdrawn. - Before Execute, a module with static initializers is checked for missing symbols. LLJIT keeps the init function of a module that fails to link, and every later input then fails. - The implicit instantiations that a failed input requested are reset. - Macros and include state are restored. GetInputCount gives a checkpoint for Undo. Undo also cleans the TU scope, reopened namespaces, replaced redeclarations and the wrapper caches. docs/UndoAndFailedInputs.rst lists what is not rolled back, and the upstream clang-repl work that can replace these workarounds. Co-developed-with-the-help-of: Claude Code (Opus 5.5, human in the loop)
ddcde50 to
646f212
Compare
|
Ignore any failures of the Windows wasm job. The out of memory issue is known, and #1172 will disable the Chromium tests on Windows for now. |
Description
In a notebook, one failed input can break every later input, and the user
must restart. clang-repl removes the declarations of a failed or undone
input, but not all the state that the input changed. The upstream work is in
progress (llvm/llvm-project#223305 and others; the new doc page lists them).
Until it lands, this PR does what CppInterOp can do with the clang API:
Declare,ProcessorEvaluatewithdraws its inputs, also whenit fails to link or to run.
Execute, a module with static initializers is checked for missingsymbols. LLJIT keeps the init function of a module that fails to link, and
every later input then fails.
[clang-repl] Roll back implicit instantiations on failed PTUs to prevent JIT starvation llvm/llvm-project#192588 does in clang-repl.
GetInputCountgives a checkpoint forUndo.Undoalso cleans theTU scope, reopened namespaces, replaced redeclarations and the enumerators
of unscoped enums. It drops only the cached wrappers that live in a
withdrawn input.
Since llvm/llvm-project#218149 (LLVM 23.1.3), clang-repl removes the members
of reopened namespaces itself, and this PR then skips that step. clang-repl
removes an undone enum, but not its enumerators.
docs/UndoAndFailedInputs.rstlists what is not rolled back, and why. Ithink each workaround can go when the matching upstream change is in all
supported LLVM versions.
The instantiation, macro and include rollback needs LLVM 22 or later.
One test changes:
VariableReflection_GetVariableOffset_UnmaterializableDefinitionrelied on a failed
Declarethat kept its class. The class is now atemplate, so the failure stays in the input that
GetVariableOffsetmakes.Type of change
Testing
New tests in
unittests/CppInterOp/InterpreterTest.cpp:Interpreter_FailedLink*,Interpreter_FailedParse*andInterpreter_Undo*.I ran
check-cppinteropagainst LLVM 22 and 23 with assertions, also withrelease/23.x, which has llvm/llvm-project#218149.compiler-research/cppjit#177 adds end-to-end notebook cases.
Checklist
🤖 Done with the help of Claude Code (Opus 5.5, human in the loop)